import 'dart:convert';

import 'package:flutterlib/common/utils/sp_utils.dart';
import 'package:flutterlib/model/share_config/qu_hui_config_entity.dart';
import 'package:flutterlib/model/user/user_entity.dart';

class AppConfigUtil{
  AppConfigUtil._();

  static const String QUHUICONFIG = "QuHuiConfig";
  static AppConfigUtil _appConfigUtil = AppConfigUtil._();

  factory AppConfigUtil(){
    return _appConfigUtil;
  }
  
  static QuHuiConfigEntity _config;

  static QuHuiConfigEntity getConfig() {
    // 读取持久化的UserInfo对象
    if (_config != null) return _config;
    String quHuiConfigJson = SpUtils.getString(QUHUICONFIG, defValue: "");
    if (quHuiConfigJson.isNotEmpty) {
      _config = QuHuiConfigEntity.fromJson(json.decode(quHuiConfigJson));
      return _config;
    }
    return null;
  }

}